﻿<Window x:Class="DataBinding.CustomListViewTest"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="DataBinding" Height="375" Width="525"
    xmlns:local="clr-namespace:DataBinding"
    >
  <Window.Resources>

    <local:ImagePathConverter x:Key="ImagePathConverter"></local:ImagePathConverter>
    
      <local:TileView x:Key="ImageView">
        <local:TileView.ItemTemplate>
          <DataTemplate>
            <StackPanel Width="150" VerticalAlignment="Top">
              <Image Source="{Binding Path=ProductImagePath, Converter={StaticResource ImagePathConverter}}"></Image>
              <TextBlock TextWrapping="Wrap" HorizontalAlignment="Center"  Text="{Binding Path=ModelName}" ></TextBlock>
            </StackPanel>
          </DataTemplate>
        </local:TileView.ItemTemplate>
      </local:TileView>

    <local:TileView x:Key="ImageDetailView" SelectedBackground="LightSteelBlue">
      <local:TileView.ItemTemplate>
        <DataTemplate>
          <Grid>
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="Auto"></ColumnDefinition>
              <ColumnDefinition Width="Auto" SharedSizeGroup="Col2"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            
            <Image Margin="5"  Width="100" Source="{Binding Path=ProductImagePath, Converter={StaticResource ImagePathConverter}}"></Image>
            <StackPanel Grid.Column="1" VerticalAlignment="Center">
              <TextBlock FontWeight="Bold" Text="{Binding Path=ModelName}"></TextBlock>
              <TextBlock Text="{Binding Path=ModelNumber}"></TextBlock>
                            <TextBlock Text="{Binding Path=UnitCost, StringFormat={}{0:C}}"></TextBlock>
            </StackPanel>
          </Grid>
        </DataTemplate>
      </local:TileView.ItemTemplate>
    </local:TileView>
    
      <GridView x:Key="GridView">
        <GridView.Columns>
          <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=ModelName}" />
          <GridViewColumn Header="Model" DisplayMemberBinding="{Binding Path=ModelNumber}" />
                <GridViewColumn Header="Price" DisplayMemberBinding="{Binding Path=UnitCost, StringFormat={}{0:C}}" />
        </GridView.Columns>
      </GridView>

    
  </Window.Resources>
  
    <Grid Margin="5">
      <Grid.RowDefinitions>
        <RowDefinition></RowDefinition>
        <RowDefinition Height="Auto"></RowDefinition>
      </Grid.RowDefinitions>
      
      <ListView Name="lstProducts" View="{StaticResource GridView}">
      </ListView>
      <Grid Grid.Row="1" Margin="5">
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto"></ColumnDefinition>
          <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <TextBlock Margin="5" VerticalAlignment="Center">Choose your view:</TextBlock>
        <ComboBox Grid.Column="1" Margin="5" Width="150" HorizontalAlignment="Left" 
                  Name="lstView" SelectionChanged="lstView_SelectionChanged">
          <ComboBoxItem>GridView</ComboBoxItem>
          <ComboBoxItem>ImageView</ComboBoxItem>
          <ComboBoxItem>ImageDetailView</ComboBoxItem>
        </ComboBox>
      </Grid>
    </Grid>
</Window>
